package com.example.demo.config;

import com.example.demo.model.CommonConst;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    @Bean(name = "HXdetail_to_jixiao")
    public Queue hebeiJiXiaoMq() {
        return new Queue("HXdetail_to_jixiao");
    }

    @Bean(name = "zhanglifeng_test")
    public Queue zhanglifengMq() {
        return new Queue("zhanglifeng_test");
    }


    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(CommonConst.MQ_EXCHANGE_NAME);
    }

    @Bean
    Binding bindHebeiJIxiao(@Qualifier("HXdetail_to_jixiao") Queue queue, DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("HXdetail_to_jixiao");//*表示一个词,#表示零个或多个词
    }

    @Bean
    Binding bindzhanglifeng(@Qualifier("zhanglifeng_test") Queue queue, DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("zhanglifeng_test");//*表示一个词,#表示零个或多个词
    }
}
